/*
=============================================
 Author:
 Student id:
 Description:
 Date:
=============================================
*/
#include <stdbool.h>
#include <stdio.h>

void task14(void) {
  printf("\n Output of task14:\n");
  printf("Enter a line of text (end with Enter):\n");
  char ch;
  scanf("%c", &ch);
  int count = 0;
  while (ch != '\n') {
    count += (ch == 'c');
    scanf("%c", &ch);
  }
  printf("The number of 'c' characters in the line is: %d\n", count);
}

void task15(void) {
  printf("\n Output of task15:\n");
  int n, sum_even = 0, sum_odd = 0, diff;

  // Prompt for input
  printf("Enter a positive integer: ");
  scanf("%d", &n);

  // Check if input is positive
  while (n <= 0) {
    printf("Warning: Input is not positive.\n");
    scanf("%d", &n);
  }

  // Calculate sums
  for (int i = 1; i <= n; i += 2) {
    sum_odd += i;
  }
  for (int i = 0; i <= n; i += 2) {
    sum_even += i;
  }

  // Calculate difference
  diff = sum_even - sum_odd;

  // Output results
  printf("Sum of even numbers: %d\n", sum_even);
  printf("Sum of odd numbers: %d\n", sum_odd);
  printf("Difference: %d\n", diff);
}

void task16(void) { 
  printf("\n Output of task16:\n"); 

  int n=5;
  for (int i = 0; i < n; i ++) {
    for (int j = 0; j <= i; j++)
      printf("*");
    printf("\n");
  }
}

void task17(void) {
  printf("\n Output of task17:\n");
  // number of lines
  int n = 5;

  // loop for each line
  for (int i = n; i > 0; i--) {
    // loop for columns
    for (int j = 0; j < 2 * i - 1; j++)
      // if i is odd, print *, else print =
      if (i % 2 == 1)
        printf("*");
      else
        printf("=");
    printf("\n");
  }
}

int main() {

  task14();
  task15();
  task16();
  task17();

  return 0;
}